package com.xsy.de.service.impl;

import com.xsy.de.entity.IUser;
import com.xsy.de.repositories.IUserRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class IUserService {

    private final IUserRepository userRepository;

    public IUserService(IUserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Transactional(readOnly = true)
    public List<IUser> findAllUser() {
        return userRepository.findAllUserInfo();
    }

    @Transactional
    public IUser addUser(IUser user) {
        return userRepository.save(user);
    }

    @Transactional(readOnly = true)
    public IUser findByName(String name) {
        return userRepository.findByName(name);
    }

    @Transactional(readOnly = true)
    public List<IUser> findUserSkill(String name, String skill) {
        return userRepository.findUserSkill(name, skill);

    }
}
